var webpack = require('webpack');
var path = require('path');

var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, './client/static/entry/index.jsx');
var BUILD_PATH = path.resolve(ROOT_PATH, './client/static/dist');
var config = {
    // 页面入口文件配置
    entry: APP_PATH,
    // 入口文件输出配置
    output: {
        path: BUILD_PATH,
        filename: 'index.js',
        publicPath: 'http://localhost:8080/'
    },
    module: {
        // 加载器配置
        loaders: [{
            "test": /\.(js|jsx)$/,
            "loader": "babel",
            "query": {
                presets: ['es2015', 'react']
            }
        }, {
            test: /\.css$/,
            loader: 'style-loader!css-loader'
        }, {
            test: /\.less$/,
            loader: 'style!css!less'
        }, {
            "test": /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
            "loader": 'url-loader?limit=50000&name=[path][name].[ext]'
        }]
    },
    // 其他解决方案配置
    resolve: {
        extensions: ['', '.js', '.jsx', '.css', '.json'],
        root: [
            path.resolve("./node_modules"),
            path.resolve("./client/static/component")
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            "process.env": {
                NODE_ENV: JSON.stringify("production")
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            comment: false,
            sourceMap: true
        })
    ]
}

module.exports = config;